/******************************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Ltd.                       */
/*                                                                            */
/*  NAME      = sqlserver_base_type.h                                         */
/*  NOTE      =                                                               */
/*  DATE      = 2014/09/28 by zhengxd                                         */
/******************************************************************************/
#ifndef _SQLSERVER_BASE_TYPE_H_
#define _SQLSERVER_BASE_TYPE_H_

#include "frmem.h"
#include "frstr.h"
#include "frcomm.h"
#include "frlist.h"
#include "frhash2.h"
#include "frlog.h"
#include "iconv2utf8.h"
#include "frsutl.h"
#include "frhex_dump.h"

#include "conntrack.h"
#include "module.h"
#include "frct_comm.h"
#include "frdb_cursor.h"
#include "frreport_comm.h"
#include "frbyte_buffer.h"
#include "frtds_convert.h"

/* UID最大字节数 */
#define MSSQL_MAX_UID_LEN         32

/* 解析返回值 */
#define MSSQL_PARSE_SUCC          0
#define MSSQL_MORE_DATA           1
#define MSSQL_PARSE_TRUE          2

/* request请求取消flag */
#define MSSQL_NOT_CANCEL          0    /* 正常响应 */
#define MSSQL_IGNORE              1    /* request最后一个packet的status与上了IGNORE */
#define MSSQL_ATTENTION           2    /* 完整的request之后发送一个attention终止请求操作 */

/* request类型 */
#define MSSQL_TDS_NUL                                 0x00
#define MSSQL_TDS_SQLBATCH                            0x01
#define MSSQL_TDS_PRETDS7LOGIN                        0x02
#define MSSQL_TDS_RPCREQUEST                          0x03
#define MSSQL_TDS_RESPONSE                            0x04
#define MSSQL_TDS_ATTENTION                           0x06
#define MSSQL_TDS_BULKLOADBCP                         0x07
#define MSSQL_TDS_TRANSMGRREQ                         0x0E
#define MSSQL_TDS_LOGIN7                              0x10
#define MSSQL_TDS_SSPIMESSAGE                         0x11
#define MSSQL_TDS_PRELOGIN                            0x12

/* RPC process ID 编号 */
#define MSSQL_PREPARE_CURSOR                          0x01
#define MSSQL_PREPARE_CURSOR_OPEN                     0x02
#define MSSQL_PREPARE_CURSOR_PREPARE                  0x03
#define MSSQL_PREPARE_CURSOR_EXECUTE                  0x04
#define MSSQL_PREPARE_CURSOR_PREPEXEC                 0x05
#define MSSQL_PREPARE_CURSOR_UNPREPARE                0x06
#define MSSQL_PREPARE_CURSOR_FETCH                    0x07
#define MSSQL_PREPARE_CURSOR_OPTION                   0x08
#define MSSQL_PREPARE_CURSOR_CLOSE                    0x09
#define MSSQL_PREPARE_EXECUTE_SQL                     0x0A
#define MSSQL_PREPARE_PREPARE                         0x0B
#define MSSQL_PREPARE_EXECUTE                         0x0C
#define MSSQL_PREPARE_PREPEXEC                        0x0D
#define MSSQL_PREPARE_PREPEXECRPC                     0x0E
#define MSSQL_PREPARE_UNPREPARE                       0x0F
/* RPC 存储过程或者远程过程调用 */
#define MSSQL_PREPARE_RPC_NAME                        0xFF
/* 所需的TDS数据 */
#define MSSQL_REQUEST                                 0
#define MSSQL_RESPONSE                                1

/* ALTMETADATA token链表 */
typedef struct __st_mssql_altmetadata_info
{
    unsigned short us_id;                /* ALTMETADATA ID */
    Frlist_header *p_lst_metadata;        /* METADATA(Sql_metadata_info *) */
} Mssql_altmetadata_info;

#endif
